﻿using MySpa.Business.Interfaces;
using MySpa.Data;
using MySpa.Data.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MySpa.Business
{
    public class CustomerService : ICustomerService
    {
        private GenericRepository<Customer> _customer;
        public CustomerService(GenericRepository<Customer> customer)
        {
            _customer = customer;
        }

        public List<Customer> GetAllCustomerWithDoBInCurrentMonth()
        {
            return _customer.GetByQuery(i =>i.IsActive && i.DateOfBirth.Value.Month == DateTime.Today.Month).ToList();
        }

        public List<Customer> GetAll(int pageSize, int pageIndex, string orderBy, out int total)
        {
            var res = _customer.GetByQuery(i => i.IsActive);
            total = res.Count();
            return res.OrderByColumnName(orderBy).Skip(pageSize * pageIndex).Take(pageSize).ToList();
        }
    }
}
